package com.beg.cant.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.beg.cant.dto.ShopSettingsRequest;
import com.beg.cant.entity.ShopSettings;
import com.beg.cant.mapper.ShopSettingsMapper;
import com.beg.cant.service.ShopSettingsService;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

@Service
public class ShopSettingsServiceImpl extends ServiceImpl<ShopSettingsMapper, ShopSettings> implements ShopSettingsService {

    @Override
    public long saveOrUpdateSettings(ShopSettingsRequest request) {
        ShopSettings settings = new ShopSettings();
        BeanUtils.copyProperties(request, settings);
        
        this.saveOrUpdate(settings);
        return settings.getId();
    }

    @Override
    public void deleteSettings(Long id) {
        this.removeById(id);
    }

    @Override
    public ShopSettings getSettings(Long id) {
        return this.getById(id);
    }
}
